package hbbft

import "go.dedis.ch/kyber/v3/share"

// 在realcrypto模式下，使用适配器转换kyber类型
func extractCryptoKeys(provider CryptoProvider, nodeID uint64, cfg Config) (
	tpkepk *TPKEPublicKey,
	tpsk *TPKEPrivateKey,
	tblspk *TBLSPublicKey,
	tblssk *TBLSPrivateKey,
) {
	// 从provider获取kyber类型
	tpkePubPoly := provider.TPKEPublic().(*share.PubPoly)
	tpkePriShare := provider.TPKEPrivateFor(int(nodeID)).(*share.PriShare)
	tblsPubPoly := provider.TBLSPublic().(*share.PubPoly)
	tblsPriShare := provider.TBLSPrivateFor(int(nodeID)).(*share.PriShare)
	
	// 转换为旧类型，传入N和T
	N := cfg.N
	T := cfg.F + 1
	tpkepk = kyberToTPKEPublicKey(tpkePubPoly, N, T)
	tpsk = kyberToTPKEPrivateKey(tpkePriShare, tpkepk)
	tblspk = kyberToTBLSPublicKey(tblsPubPoly, N, T)
	tblssk = kyberToTBLSPrivateKey(tblsPriShare, tblspk)
	
	return
}

